1. Field of the Invention
This invention relates to graphical image manipulation systems, and more particularly to a method and system for compositing graphical images.
2. Description of Related Art
A number of graphic image manipulation computer programs build up a final image by compositing several image layers together. An example of one such program is Adobe Photoshop 3.0, from Adobc Systems, Inc. of Mountain View, Calif.
Referring to FIG. 1, each image layer 10 typically comprises the actual image information 12, compositing parameters 14, and, optionally, a mask 16. As is known in the art, the image 12 generally comprises a set of pixels in an m.times.n array. The compositing parameters 14 generally include such information as a transfer mode (e.g., color model), global opacity information, color-based restrictions on which areas are subject to blending, and other information known in the art.
A number of image layers, 1 . . . n, are merged to form a composite image. In the merge process, each pixel generally is independent of the other pixels of the image 12 within each image layer 10, so an implementing system can equally well calculate pixel data for the entire final image, or just a piece of the final image. FIG. 2 is a block diagram showing diagrammatically that a set of image layers 20 are subjected to a compositing operation 22 to generate a merged image 24, in known fashion. The process of merger may also be represented by the following pseudocode:
______________________________________ PROCEDURE CalculateMergedData (layers: ARRAY OF ImageLayer; result: Image); VAR i: INTEGER; BEGIN InitializeMergedData (result); FOR i = 1 TO LEN(layers) DO CompositeImageIntoImage ( layers[i].image, layers[i].compositingParameters, layers[i].mask, result) END FOR END CalculateMergedData; ______________________________________
In the pseudocode above, the final image, "result", can be initialized either to a solid color or to a value representing transparency.
In existing image manipulation programs, there is a large class of useful image effects based upon functions that are applied to each pixel of an image independently. These functions include operations like inverting the color at a pixel, increasing the brightness of all pixels, etc. Such functions typically are known as "adjustments", and are selectable via a user interface (e.g., menu or icons) of an implementing program, such as Adobe Photoshop 3.0 referenced above. A key property that sets these functions apart from filters (such as blurring operations), is that each pixel in the result only depends on the spatially corresponding. pixel in the source image. Adjustment operations generally involve applying a particular function to some pixels based on some global parameters. In addition, frequently a mask is specified to constrain the effect. An adjustment operation is typically invoked by a call to a function such as the following, which specifies an adjustment function and parameters and the mask constraining that function:
______________________________________ ApplyAdjustmentToImage ( adjustmentFunction, adjustmentParameters, mask, image) ______________________________________
When applying an adjustment function, the mask is frequently accounted for by using separate images for the initial and adjusted data, and then using the mask to compute a weighted average of the two images. This may require the use of a temporary buffer to hold a copy of the initial image, or to hold the adjusted data before blending it into the original data. This could, for example, result in a code path like the following:
______________________________________ ApplyAdjustmentNoMaskFromImageToImage ( adjustmentFunction, adjustmentParameters, image, tmpImage); BlendImages (tmpImage, image, mask, image); ______________________________________
FIG. 3A is a block diagram showing an image 30 to which is applied one or more adjustments 32 to generate an adjusted image 34, in accordance with the prior art. Thus, for example, an image X may be color corrected by an adjustment to generate image X'.
FIG. 3B is a block diagram showing diagrammatically the application of a simple adjustment to a merged image, in accordance with the prior art. The adjustment data may be stored, for convenience, as a "pseudo-layer" 36, so that the data is part of the array of actual image layers 1 . . . n. The image layers 20 are merged by the application of a compositing operation 22 into a merged image 24. The adjustment function 36 is then applied 38 to the merged image 24 to generate an adjusted merged image 24'. Accordingly, adjustment operations can be readily incorporated into a conventional layer merging process in accordance with the following pseudocode:
______________________________________ TYPE Layer= OBJECT mask: Image ImageLayer= OBJECT EXTENDING Layer image: Image; compositingParameters: CompositingParameters END; SimpleAdjustmentLayer= OBJECT EXTENDING Layer adjustmentFunction: AdjustmentFunction ; adjustmentParameters: AdjustmentParameters END; PROCEDURE CalculateMergedData (layers: ARRAY OF Layer; result: Image); VAR i: INTEGER; BEGIN InitializeMergedData (result); FOR i = 1 TO LEN(layers) DO IF layers[i] IS ImageLayer DO WITH layers[i] AS ImageLayer DO CompositeImageIntoImage ( layers[i].image, layers[i].compositingParameters, layers[i].mask, result ) END WITH ELSIF layers[i] IS SimpleAdjustmentLayer DO WITH layers[i] AS SimpleAdjustmentLayer DO ApplyAdjustmentToImage ( layers[i].adjustmentFunction, layers[i].adjustmentParameters, layers[i].mask, result ) END WITH ELSE (* Unexpected layer type! *) END IF END FOR END CalculateMergedData; ______________________________________
(In the above pseudocode, types declared as OBJECTs are polymorphic records, which are generally accessed via pointers. When an object is declared as EXTENDING another OBJECT type, the object inherits all of the fields of the extended object type. Thus, in the example above, OBJECTs "ImageLayers" and "SimpleAdjustmentLayers" have "mask" fields which they inherit from OBJECT "Layer". The IS expression tests whether a particular object is really a specified extension of its declared type. The WITH statement casts an object to an extension, allowing the program to access fields only defined in that extension--the IS test indicates that it is safe perform this cast.)
In the above pseudocode, for each conventional image layer 1 . . . n (having type "ImageLayer"), conventional compositing 22 is performed to generate the merged image 24. When the simple adjustment layer 36 (having type "SimpleAdjustmentLayer") is detected, the adjustment function is applied 38 to the entire merged image 24 stored in variable "result" to generate the adjusted merged image 24'.
A drawback of the prior products implementing simple adjustment layers is that they do not allow the system to edit the data underneath an adjustment "layer" while viewing the adjustment as applied to the final result. That is, the adjustment function does not truly have characteristics of an image layer. Further, the range of effects presented is generally quite limited.
Accordingly, it would be useful to have greater flexibility in applying adjustments to composited images. The present invention provides the system and method for allowing such flexibility.